-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
전남대 FE_이도현_3주차 과제 #51
base: leedyun
Are you sure you want to change the base?
Conversation
src/api/api.tsx
Outdated
import axios from 'axios'; | ||
import { useQuery } from 'react-query'; | ||
|
||
import type {GoodsData,InfiniteQueryResponse,ThemeData } from '@/types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import type {GoodsData,InfiniteQueryResponse,ThemeData } from '@/types'; | |
import type { GoodsData,InfiniteQueryResponse,ThemeData } from '@/types'; |
} | ||
|
||
|
||
export const fetchRankingProducts = async (targetType: string, rankType: string): Promise<GoodsData[]> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api 호출의 성공 실패시 핸들링은 추가해주신 react-query
에서만 수행하면 될 거 같습니다.
여기서는 api 함수만 정의해주시면 될 거 같아요.
const fetchRankingProducts = await axiosInstance.get('api/v1/ranking/products', {
params: { targetType, rankType }
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 fetchThemeProducts
, fetchTheme
도 마찬가지 입니다.
['rankingProducts', filterOption], | ||
() => fetchRankingProducts(filterOption.targetType, filterOption.rankType), | ||
{ | ||
keepPreviousData: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이전 데이터를 사용하지 않는데 해당 플래그는 왜 true 로 설정했을까요 ?
const [themes, setThemes] = useState<ThemeData[]>([]); | ||
|
||
useEffect(() => { | ||
const loadThemes = async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 api 도 react-query
사용하면 되지 않을까요 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요 멘토님 항상 피드백 감사합니다. 피드백 주신 내용은 모두 수정했습니다
(아마 위에 플래그나 지저분한 코드의 문제는 문제 해결 도중 에러가 뜰 때 이것저것 만져보고 안 되돌려서 생긴 문제같습니다:) )
추가적인 피드백 내용 있으면 알려주세요! 감사합니다!
(혹시 merge는 안 해주시는건가요..? 1주차때부터 머지가 안 되어있어서... 제가 추가로 코드를 더 수정해야하는걸까요?)
3주차 과제 step4까지 제출합니다.